<!DOCTYPE HTML>
<html>
<head>
   <meta charset="UTF-8" />
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
    <title>title</title>
    <script type="text/javascript" src="../../script/s94.js#debug"></script>
    <script type="text/javascript" src="../../script/s94.app.js"></script>
    <!--公共部分-->
    <script type="text/javascript" src="../../script/common.js"></script>
    <link href="../../css/common.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
	.body{font-size: 0.28rem;}
	.body .button{margin: 0.1rem;}
	.title{width: 100%;margin: 0.6rem 0 0.2rem 0;text-align: center;font-size: 0.36rem;font-weight: bold;}
</style>
<body>
	<header class="public">
		<a app href="back" target="_blank"><i ico class="ico-fx-l"></i></a>
		<div class="set-xy full">模块测试</div>
	</header>
	<div class="body">
		<br>
		<div class="button test">测试</div>

		<br>
        <div class="button" act="ajax">ajax</div>
	</div>
</body>
<script type="text/javascript">
//每个方法传递的参数
var params = {
	ajax : {
		'url': 'http://sunjl.hmcq.cn:8080/test.php',
		headers: {
			"ssss": "dddddd",
			"cookie": "name=123"
		},
		data: {
			"name": "123",
			"pass": "123456"
		},
	}
	
}
$.app(function(){ //APP加载完成后执行回调函数，等效于apicloud的apiready方法
	var md = $.app("http");//等效于api.require(module);
	//所有按钮统一绑定事件
	$('.button[act]').on("click",function(){
		var act = $(this).attr("act"); //获取需要执行的方法名称
		var param = params[act]; //获取执行的方法需要传递的参数
		switch (typeof(param)) {
			case 'underfind': param = {};break;
			case 'function': param = param();break;
		}
		md[act](param, function(res, err){
			$.log(res, act+'[OK]');
			$.log(err, act+'[err]');
		})
	})
	
	$('.button.test').on('click', function(){
		$.log("test");
		api.ajax({
			url: 'http://sunjl.hmcq.cn:8080/test.php',
			dataType: 'text',
			returnAll: true,
		}, function(res, err){
			$.log(res, 'api.ajax[OK]');
			$.log(err, 'api.ajax[err]');
		})
		md.test({
			url: 'http://sunjl.hmcq.cn:8080/test.php',
		}, function(res, err){
			$.log(res, 'test[OK]');
			$.log(err, 'test[err]');
		})
	})
})
</script>
</html>
